package com.hotec.PROJECT_NAME.component.basic;

import com.gemcap.framework.data.auth.GcAuthentication;
import com.hotec.PROJECT_NAME.modules.sys.entity.SysAccount;
import com.hotec.PROJECT_NAME.utils.UtilsAccount;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author 黑山老妖
 * @date 2018/9/28
 */
public class BaseBase implements GcAuthentication<SysAccount> {
    /**
     * 获取当前登录账号的username
     *
     * @param strict
     * @return
     */
    @Override
    public String getCurrentAccountId(Boolean... strict) {
        return UtilsAccount.getCurrentAccountId(strict);
    }

    public SysAccount getCurrentAccount(Boolean... strict) {
        return UtilsAccount.getCurrentAccount(strict);
    }

    public String getCurrentReqClient (){
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();

        return request.getHeader("client");
    }

    public List<String> getCurrentAccountRoles(Boolean... strict) {
        return UtilsAccount.getCurrentAccountRoles(strict);
    }


}
